package com.jd.xsl.field;

public class NumberFormat extends FieldFormat {

	private static final long serialVersionUID = 549718600228503001L;
	private int precision;
	private int scale;
	private String max;
	private String min;

	/**
	 * @return the precision
	 */
	public int getPrecision() {
		return precision;
	}

	/**
	 * @param precision
	 *            the precision to set
	 */
	public void setPrecision(int precision) {
		this.precision = precision;
	}

	/**
	 * @return the scale
	 */
	public int getScale() {
		return scale;
	}

	/**
	 * @param scale
	 *            the scale to set
	 */
	public void setScale(int scale) {
		this.scale = scale;
	}

	/**
	 * @return the max
	 */
	public String getMax() {
		return max;
	}

	/**
	 * @param max
	 *            the max to set
	 */
	public void setMax(String max) {
		this.max = max;
	}

	/**
	 * @return the min
	 */
	public String getMin() {
		return min;
	}

	/**
	 * @param min
	 *            the min to set
	 */
	public void setMin(String min) {
		this.min = min;
	}

	@Override
	public String toString(){
		StringBuilder builder = new StringBuilder("{");

		builder.append("\"type\":\"number\"");

		builder.append(", \"precision\":").append(precision);
		builder.append(", \"scale\":").append(scale);

		if (max != null && !"".equals(max.trim())){
			builder.append(", \"max\":").append(max);
		}

		if (min != null && !"".equals(min.trim())){
			builder.append(", \"min\":").append(min);
		}

		return builder.append("}").toString();
	}
}
